﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class SpikedBall2Ctl : PlatformCtl
{
    private LineRenderer line;

    private Transform chainTransform;
    private Transform ballTransform;

    public override void Start()
    {
        base.Start();

        Transform[] childTransforms = GetComponentsInChildren<Transform>();
        foreach (Transform trans in childTransforms)
        {
            if (trans.gameObject.name == "Chain")
            {
                chainTransform = trans;
            }
            else if (trans.gameObject.name == "Spiked Ball")
            {
                ballTransform = trans;
            }
        }
        line = GetComponent<LineRenderer>();
    }

    public override void Update()
    {
        base.Update();

        line.SetPosition(0, chainTransform.position);
        line.SetPosition(1, ballTransform.position);
    }

}
